<template>
  <div>
    <el-card>
      <!-- 档案信息 -->
      <info-model :params="paramsId"></info-model>
      <!-- 档案信息 end-->

      <!-- 检验档案信息 -->
      <div class="info mt20">
        <div class="info-title">检验档案信息</div>
        <div class="info-content">
          <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" class="queryParams">

            <el-form-item label="检验项目流水号:" prop="logId">
              <el-input v-model="queryParams.logId" placeholder="请输入检验项目流水号" clearable style="width: 180px;" size="small" @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="检验项目流水号:" prop="logId">
              <el-input v-model="queryParams.logId" placeholder="请输入检验项目流水号" clearable style="width: 180px;" size="small" @keyup.enter.native="handleQuery" />
            </el-form-item>

            <el-form-item label="检验报告日期:" prop="logId">
              <el-date-picker v-model="queryParams.data" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions">
              </el-date-picker>

            </el-form-item>
            <el-form-item label="检验报告结果:" prop="logId">
              <el-select v-model="queryParams.inspectionReportResultList" placeholder="请选择检验报告结果" clearable size="small" style="width: 180px">
                <el-option :label="item.label" :value="item.value" v-for="item in inspectionReportResultList" :key="item.id" />
              </el-select>
            </el-form-item>

            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

            </el-form-item>
          </el-form>

          <el-table ref="tables" v-loading="loading" :data="list" stripe highlight-current-row @selection-change="handleSelectionChange">

            <!-- <el-table-column type="selection" width="55" align="center" /> -->

            <el-table-column label="门(急)诊号" prop="logId" width="300" show-overflow-tooltip />
            <el-table-column label="库/表名" prop="schemaTable" width="300" show-overflow-tooltip />
            <el-table-column label="库/表名" prop="schemaTable" width="300" show-overflow-tooltip />
            <el-table-column label="库/表名" prop="schemaTable" width="300" show-overflow-tooltip />
            <el-table-column label="库/表名" prop="schemaTable" width="300" show-overflow-tooltip />
            <el-table-column label="操作时间" prop="createTime" width="150" show-overflow-tooltip />

            <el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width" fixed="right">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-download" @click="handleExport(scope.row)">导出</el-button>
              </template>
            </el-table-column>
          </el-table>

          <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :page-sizes="[8,10, 20, 30, 50]" :limit.sync="queryParams.pageSize" @pagination="getList" />

        </div>
      </div>
      <!-- 档案信息 end-->

    </el-card>
  </div>
</template>

<script>

import { listLog } from "@/api/areaSystem/synchronizationLog";
/* 档案信息 */
import infoModel from './../model/infoModel.vue'
export default {
  /*  档案信息 */
  components: { infoModel },
  data() {
    return {
      // 遮罩层
      loading: true,
      //接收id
      paramsId: this.$route.query.id,

      // 选中数组
      ids: [],
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      /* 选择日期 快捷数据 */
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }, {
          text: '一月前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', date);
          }
        }]
      },

      // 检验报告结果 列表
      inspectionReportResultList: [{
        id: 0,
        value: '',
        label: '全部'
      }, {
        id: 1,
        value: '1',
        label: '正常'
      }, {
        id: 2,
        value: '2',
        label: '异常'
      }],
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {

        //执行结果
        executeResultCode: '',
        //日志id
        logId: '',
        createTime: '',
        updateTime: '',
        pageNum: 1,
        pageSize: 8

      }

    }

  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询同步日志 */
    getList() {
      this.loading = true;
      listLog(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      }
      );
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");

      this.handleQuery();
    },
    /** 多选框选中数据 */
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.operId)
      this.multiple = !selection.length
    },


    /** 导出按钮操作 */
    handleExport(row) {
      console.log("导出按钮操作", row)
    },

  }
}
</script>

